package com.example;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

/**
 * @ Author: XuDi
 * @ Date: 2022/11/26 12:48
 */
public class TessDemo {
    public static void main(String[] args) {
        String path = "C:\\Users\\YOLO\\Desktop\\3.png";
        File imageFile = new File(path);
        ITesseract instance = new Tesseract();  // JNA Interface Mapping
        instance.setDatapath("D:\\document\\tessdata"); // path to tessdata directory
        instance.setLanguage("chi_sim");
        try {
            String result = instance.doOCR(imageFile);
            System.out.println(result);
        } catch (TesseractException e) {
            System.err.println(e.getMessage());
        }
    }
}
